<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RandomProductWidget
 *
 * @author Lawrence
 */
class RandomProductWidget extends CWidget {
    
    public $category_id;
    
    public function run(){
        $product = Product::model()->findAll(array(
            'condition' => 'category_id = :cate_id',
            'params' => array(
                ':cate_id' => $this->category_id,
            ),
            'order' => 'RAND()',
            'limit' => 5
        ));
        
        $this->render('RandomProductWidget', array(
            'products' => $product
        ));
    }
}

?>
